package com.wodsy.phoenix.dataobject.goodsc.model.search;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.NumericField;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Store;

import com.wodsy.phoenix.dataobject.base.PhoenixObject;
import com.wodsy.phoenix.dataobject.base.PhoenixRequest;
import com.wodsy.phoenix.dataobject.base.PhoenixResponse;
import com.wodsy.phoenix.dataobject.goodsc.model.search.GoodsSaleProperty;

/**
 * TbGoods entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_goods", catalog = "goodsc")
@Indexed(index="SearchGoods")
public class SearchGoods extends PhoenixObject implements java.io.Serializable,PhoenixRequest,PhoenixResponse {

	// Fields
	private static final long serialVersionUID = 1L;
	
	private Integer id;     //商品id   
	
	@Field(name="name",index=Index.TOKENIZED,store=Store.YES)
	private String name;   //商品名称
	private String title;  //商品副标题
	private String number;    //作品货号
	private Integer shopId;      //商品关联的店铺id
	private Integer ftId;       //运费模版id
	
	@Field(name="addTime",index=Index.UN_TOKENIZED,store=Store.YES)
	@DateBridge(resolution=Resolution.SECOND)  
	private Date addTime;         //商品添加时间
	
	private Date updateTime;     //商品修改时间
	private Boolean customization;     //是否定制，1为定制
	private Short status;              //商品状态
	
	@Field(name="price",index=Index.UN_TOKENIZED,store=Store.YES)
	@NumericField
	private Integer price;             //商品默认价格   单位为分
	
	@Field(name="pic",index=Index.NO,store=Store.YES)
	private String pic;                //商品默认图片，用于搜索展示
	private String piclist;				//商品作品主图组，最多为五张。 存储形式为  ：  a/b/0.jpg#$#a/b/1.jpg
	private Integer typeId;				//商品对应的分类id
	private Integer weight;				//商品重量      单位为克
	private Integer volume;				//商品体积     单位为立方厘米
	private String designer;            //设计师名称
	
	@Field(name="shopName",index=Index.NO,store=Store.YES)
	private String shopName;			//店铺名称
	
	private GoodsSaleProperty goodsSaleProperty;
	
	// Constructors

	/** default constructor */
	public SearchGoods() {
	}

	/** minimal constructor */
	public SearchGoods(String name, Integer shopId, Integer ftId, Date addTime) {
		this.name = name;
		this.shopId = shopId;
		this.ftId = ftId;
		this.addTime = addTime;
	}

	/** full constructor */
	public SearchGoods(String name, String title, String number,Integer shopId, Integer ftId,
			Date addTime, Date updateTime, Boolean customization,
			Short status, Integer price, String pic, String piclist,
			Integer typeId, Integer weight, Integer volume,String shopName,String designer) {
		this.name = name;
		this.title = title;
		this.number = number;
		this.shopId = shopId;
		this.ftId = ftId;
		this.addTime = addTime;
		this.updateTime = updateTime;
		this.customization = customization;
		this.status = status;
		this.price = price;
		this.pic = pic;
		this.piclist = piclist;
		this.typeId = typeId;
		this.weight = weight;
		this.volume = volume;
		this.shopName = shopName;
		this.designer = designer;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "title", length = 50)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "number", length = 11)
	public String getNumber() {
		return this.number;
	}

	public void setNumber(String number) {
		this.number = number;
	}


	@Column(name = "shop_id", nullable = false)
	public Integer getShopId() {
		return this.shopId;
	}

	public void setShopId(Integer shopId) {
		this.shopId = shopId;
	}

	@Column(name = "ft_id", nullable = false)
	public Integer getFtId() {
		return this.ftId;
	}

	public void setFtId(Integer ftId) {
		this.ftId = ftId;
	}

	@Column(name = "add_time", nullable = false, length = 19)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "customization")
	public Boolean getCustomization() {
		return this.customization;
	}

	public void setCustomization(Boolean customization) {
		this.customization = customization;
	}

	@Column(name = "status")
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	@Column(name = "price")
	public Integer getPrice() {
		return this.price;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	@Column(name = "pic", length = 100)
	public String getPic() {
		return this.pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	@Column(name = "piclist", length = 200)
	public String getPiclist() {
		return this.piclist;
	}

	public void setPiclist(String piclist) {
		this.piclist = piclist;
	}

	@Column(name = "type_id")
	public Integer getTypeId() {
		return this.typeId;
	}

	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}

	@Column(name = "weight")
	public Integer getWeight() {
		return this.weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	@Column(name = "volume")
	public Integer getVolume() {
		return this.volume;
	}

	public void setVolume(Integer volume) {
		this.volume = volume;
	}

	@Column(name="shop_name")
	public String getShopName() {
		return shopName;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}
	
	@Column(name="designer")
	public String getDesigner() {
		return designer;
	}

	public void setDesigner(String designer) {
		this.designer = designer;
	}

	@OneToOne(cascade=CascadeType.PERSIST)
	@IndexedEmbedded
	@JoinColumn(name="sale_id")
	public GoodsSaleProperty getGoodsSaleProperty() {
		return goodsSaleProperty;
	}

	public void setGoodsSaleProperty(GoodsSaleProperty goodsSaleProperty) {
		this.goodsSaleProperty = goodsSaleProperty;
	}
	
}